package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.Major;
import com.ruoyi.system.mapper.MajorMapper;
import com.ruoyi.system.service.IMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * MajorService class provides methods to perform CRUD operations on Major entity.
 */
@Service
public class MajorService implements IMajorService {

    @Autowired
    private MajorMapper majorMapper;

    @Override
    public List<Major> selectMajorList(Major major) {
        List<Major> majors = majorMapper.selectMajorList(major);
        return majors;
    }

    @Override
    public String insertMajor(Major major) {
        int i = majorMapper.insertMajor(major);
        if(i==1){
            return "添加成功";
        }else {
            return "添加失败";
        }

    }

    @Override
    public String deleteMajor(List<Major> majors) {
        for (Major major : majors) {
            int i = majorMapper.deleteMajor(major);
            if(i==0){
                return "删除失败";
            }
        }
        return "删除成功";
    }

    @Override
    public String updateMajor(Major major) {
        int i = majorMapper.updateMajor(major);
        if(i==1){
            return "修改成功";
        }else {
            return "修改失败";
        }
    }

    @Override
    public List<Major> selectPostList(Major major) {

        return majorMapper.selectPostList(major);
    }

    @Override
    public int deletePostByIds(Long[] postIds) {
        return majorMapper.deletePostByIds(postIds);
    }


}
